home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13649 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.7 KB

  1. Path: druid.borland.com!usenet
  2. From: mstave@wpo.borland.com (Matt Stave)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: BC++ 4.52 - A CodeGuard bug, or mine?
  5. Date: Tue, 26 Mar 1996 19:29:15 GMT
  6. Organization: Borland International
  7. Message-ID: <4j9gk1$efj@druid.borland.com>
  8. References: <4j6ubq$24l@clarknet.clark.net>
  9. NNTP-Posting-Host: mstave2.borland.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Joe,
  13.  
  14. When CodeGuard detects an invalid delete, it attempts to tell you
  15. where the pointer was allocated.  
  16.  
  17. It could be that the value of the pointer has changed between the
  18. allocation and the deletion.  A changed memory global breakpoint may
  19. catch this.   In addition, you could do:
  20.  
  21.    a = new ...
  22.    b = a;
  23.    ...
  24.    assert ( b==a );
  25.    delete [] a;
  26.  
  27. Another possibility is heap corruption, take a look at the RTL's heap
  28. checking functions for more info.
  29.  
  30. Let me know how it goes.
  31.  
  32. --- Matt (Borland)
  33.  
  34.  
  35. budge@clark.net (Joe Budge) wrote:
  36.  
  37. >I am experiencing a sporadic error message from CodeGuard which
  38. >makes no sense to me.  Any tips that anyone can provide as to
  39. >what the cause may be or how I may narrow this down would be
  40. >greatly appreciated.
  41.  
  42. >I'm building an application under BCPP 4.53 for Windows 3.11
  43. >using the large memory model.  At inconsistent times CodeGuard
  44. >interrupts with a 'Bad Parameter' message: 'A bad object
  45. >(0x00000000) has been passed to the function. delete(0xhhhh:hhhh)"
  46. >[Where h = address of delete() in my .exe].  The lowest level
  47. >of the call stack with source code always points to the line
  48. >containing the 'new' operator in one of several code fragments
  49. >that look like:
  50.  
  51. >    char * szDest ;
  52. >    szDest = new char[n + 1] ;
  53. >    assert( szDest != NULL ) ;
  54.  
  55. >This is puzzling, as I am not calling delete() anywhere that I
  56. >can tell in the flagged code (yes, I do call it elsewhere).  I
  57. >can't find anywhere that the BC++ source for operator new() calls
  58. >delete() either.
  59.  
  60. >In the above fragment, 'n' is of type size_t and is passed to the
  61. >function containing the code fragment as a parameter.  There doesn't
  62. >seem to be any relationship between its value and the failure.
  63.  
  64. >If I set a breakpoint on the offending line or break elsewhere and
  65. >set watches on either of the variables involved, the failure never
  66. >occurs.  This means I can't tell what's really going on.  I've tried
  67. >initializing szDest to different values - doesn't make a difference.
  68.  
  69. >Of course I've checked the installation of CodeGuard.  There is
  70. >no apparent problem if I build & run without CodeGuard, and there's
  71. >no apparent problem if I build & run for 32-bit windows.  Now I'm at
  72. >wit's end and am beginning to suspect that the problem is in
  73. >CodeGuard, not in anything I've done.  Any suggestions would be
  74. >greatly appreciated.
  75.  
  76. >Thanks in advance,
  77. >Joe Budge
  78.  
  79.  
  80.  
  81.  
  82.